//引入mockjs
import Mock from 'mockjs'
const Random = Mock.Random
const baseURL = process.env.VUE_APP_BASE_API

/**封装mock
 * @param(rurl)   api地址
 * @param(rtype)  请求方式
 * @param(res)    模拟数据
 */
function mockF(rurl, rtype, res) {
  const url = baseURL + rurl
  Mock.mock(url, rtype, res)
}

//筛选列表
const getFilterListData = () => {
  let Data = []
  for (let i = 0; i < 10; i++) {
    Data.push({
      Id: i,
      Name: Random.cword(3)
    })
  }
  let State = 1,
    res = { State, Data }

  return res
}
mockF('/Store/getFilterList', 'post', getFilterListData)

// 商家分页
const shopListData = () => {
  let Data = []
  for (let i = 0; i < 10; i++) {
    Data.push({
      Id: i,
      Logo: '',
      Name: Random.cword(3),
      BusinessHours: Random.time() + '-' + Random.time(),
      tags: [{ Name: Random.cword(3) }, { Name: Random.cword(4) }],
      Distance: 3000
    })
  }
  let State = 1,
    res = { State, Data }
  return res
}
mockF('/Store/GetPageListByType', 'post', shopListData)

// 商家详情
const getDetailInfoData = () => {
  let Data = {
    Id: 1,
    Logo: '',
    Name: Random.cword(3),
    BusinessHours: Random.time() + '-' + Random.time(),
    tags: [{ Name: Random.cword(3) }, { Name: Random.cword(4) }],
    Distance: 3000,
    ShopSign:
      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600949326496&di=53ee9a05d3ed0b88b189c29a67d91e0e&imgtype=0&src=http%3A%2F%2Ft8.baidu.com%2Fit%2Fu%3D1484500186%2C1503043093%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D1280%26h%3D853,,https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600949326496&di=53ee9a05d3ed0b88b189c29a67d91e0e&imgtype=0&src=http%3A%2F%2Ft8.baidu.com%2Fit%2Fu%3D1484500186%2C1503043093%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D1280%26h%3D853'
  }
  let State = 1,
    res = { State, Data }
  return res
}
mockF('/Store/GetDetailInfo?id=1', 'post', getDetailInfoData)
